//
//  LsBaseController.m
//  MIC_MoveModelExample
//
//  Created by 李爽 on 15/11/13.
//  Copyright (c) 2015年 Shawn Li. All rights reserved.
//

#import "LsBaseController.h"

@implementation LsBaseController
- (void)viewDidLoad {
    [super viewDidLoad];
    
}


/**
 *  设置导航栏图片和字体颜色
 */
- (void)setNavBarImage {
    UIImage *image = [UIImage imageNamed:@"navigation_bar_img"];
    [self.navigationController.navigationBar setBackgroundImage:image forBarMetrics:UIBarMetricsDefault];
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
    NSDictionary *attribute = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:18.0]};
    [self.navigationController.navigationBar setTitleTextAttributes:attribute];
}


/**
 *  设置状态栏样式
 *
 *  @param style 样式
 */
- (void)setStatusBarStyle:(UIStatusBarStyle)style {
    [[UIApplication sharedApplication] setStatusBarStyle:style];
}


- (void)setNavigationRightView {
    UIView *rightView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60, 44)];
    UIButton *searchBtn = [self customButtonWithImage:@"search.png" selector:@selector(doSearch:)];
    UIButton *locationBtn = [self customButtonWithImage:@"location_img.png" selector:@selector(doLocation:)];
    
    [rightView addSubview:searchBtn];
    [rightView addSubview:locationBtn];
    
    CGRect frame = locationBtn.frame;
    frame.origin.x = 30;
    locationBtn.frame = frame;
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:rightView];
    self.navigationItem.rightBarButtonItem = item;
}

- (void)setNavigationLeftView:(NSString *)name {
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithTitle:name style:UIBarButtonItemStyleBordered target:self action:@selector(doLeft:)];
    self.navigationItem.leftBarButtonItem = item;
}


- (UIButton *)customButtonWithImage:(NSString *)imageName selector:(SEL)selector {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 0, 30, 44);
    [button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
    [button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];
    
    return button;
}

#pragma mark - 事件
- (void)doSearch:(UIButton *)sender {

}

- (void)doLocation:(UIButton *)sender {

}

- (void)doLeft:(UIButton *)sender {

}

@end
